const { tab } = require('./mock')
const bodyParser = require('body-parser')
module.exports = app => {
	app.use(bodyParser.json())
	app.get('/api/tab', (req, res) => res.send({
		code: 200,
		data: tab
	}))

	app.post('/api/detail', (req, res) => {
		const { id } = req.body;
		tab.forEach(v => {
			const result = v.children.find(v => v.id === id)
			if(result) {
				res.send({
					code: 200,
					data: result
				})
			}
		})
	})
}